Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to change the color of the material passed in shipout/background #4

Closed
dbitouze opened this issue Apr 28, 2021 · 13 comments
Closed

Comments

@dbitouze
Copy link

dbitouze commented Apr 28, 2021

The luacolor package makes impossible to change the colour of the material passed in "shipout/background", as shown in the following example, which typesets "DRAFT":

  • in red if luacolor is not called ;
  • in black otherwise.
\documentclass{article}
\usepackage{xcolor}
% \usepackage{luacolor}
\usepackage{lipsum}
\AddToHook{shipout/background}
{%
  \put(0.5\paperwidth,-0.5\paperheight)
  {%
    \makebox[0pt][c]{\Huge\color{red}DRAFT}
  }%
}
\begin{document}
\lipsum[1-5]
\end{document}
@u-fischer
Copy link

It will work in the next LaTeX version (it already works with lualatex-dev).

@dbitouze
Copy link
Author

dbitouze commented May 26, 2021

It will work in the next LaTeX version (it already works with lualatex-dev).

With lualatex-dev (LuaHBTeX, Version 1.13.2), works nicely with \color{...} but not with \color_fill:n {...}:

\documentclass{article}
\usepackage{luacolor}
\usepackage[paperheight=2cm,paperwidth=3cm]{geometry}
\ExplSyntaxOn
\AddToHook{shipout/background}
{%
  \put(0.5\paperwidth,-0.5\paperheight)
  {%
    \makebox[0pt][c]{
      \color_fill:n {red}
      RED?
      \color{red}
      RED!
    }
  }%
}
\ExplSyntaxOff
\begin{document}
\mbox{}
\end{document}

image

@u-fischer
Copy link

luacolor doesn't work with l3color at all currently. That is a unrelated issue.

@dbitouze
Copy link
Author

luacolor doesn't work with l3color at all currently. That is a unrelated issue.

OK. I guess it is useless to open a feature request for this 😄

@u-fischer
Copy link

@dbitouze well you can play around with this here. That is only temporary, we will have to discuss how to integrate this properly.
(I didn't tested properly if the fill and stroke code actually works correctly)

\documentclass{article}
\usepackage{luacolor}
\ExplSyntaxOn \makeatletter
\cs_set_protected:Npn \__color_backend_select:nn #1#2
  { 
    \LuaCol@setattribute\LuaCol@Attribute
     {
       \directlua{oberdiek.luacolor.get("\luaescapestring{#1~#2}")}
     }
  }
\cs_set_protected:Npn \__color_backend_fill:n #1
  {    
    \LuaCol@setattribute\LuaCol@Attribute
     {
       \directlua{oberdiek.luacolor.get("\luaescapestring{#1}")}
     }
  }
\cs_set_protected:Npn \__color_backend_stroke:n #1
  {    
    \LuaCol@setattribute\LuaCol@Attribute
     {
       \directlua{oberdiek.luacolor.get("\luaescapestring{#1}")}
     }
  }  
\cs_set_protected:Npn \__color_backend_reset:{ }
  
\ExplSyntaxOff  \makeatother
\begin{document}

\ExplSyntaxOn
   \makebox[0pt][c]{
   \color_select:n {blue} Blue 
   \color_fill:n {red} Red?
      \color{red}
      RED!
    }
\ExplSyntaxOff
\mbox{}
\end{document}

@dbitouze
Copy link
Author

well you can play around with this here.

Thanks! But, unfortunately:

! LaTeX3 Error: Control sequence \__color_backend_select:nn already defined

@u-fischer
Copy link

Ah, sorry. Load expl3 and the backend first. E.g. with \usepackage{expl3}. My documents actually all start with this

\RequirePackage{expl3}
\ExplSyntaxOn
\pdf_uncompress:
\ExplSyntaxOff

\documentclass{article}

@dbitouze
Copy link
Author

E.g. with \usepackage{expl3}

Works nicely now. Is there any reason for \ExplSyntaxOn \makeatletter...\ExplSyntaxOff \makeatother to not be properly nested?

@dbitouze
Copy link
Author

dbitouze commented Jun 9, 2021

luacolor doesn't work with l3color at all currently. That is a unrelated issue.

Interestingly, as far as l3color's \color_fill:n is concerned, the following MCE compiled with lualatex:

  • works as expected with:
 *File List*
 article.cls    2020/04/10 v1.4m Standard LaTeX document class
  size10.clo    2020/04/10 v1.4m Standard LaTeX file (size option)
luacolor.sty    2021-02-17 v1.17 Color support via LuaTeX's attributes (HO)
   color.sty    2020/02/24 v1.2b Standard LaTeX Color (DPC)
   color.cfg    2016/01/02 v1.6 sample color configuration
  luatex.def    2020/10/05 v1.2a Graphics/color driver for luatex
atbegshi-ltx.sty    2020/08/17 v1.0a Emulation of the original atbegshi package
  with kernel methods
l3backend-luatex.def    2021-05-07 L3 backend support: PDF output (LuaTeX)
  ts1cmr.fd    2019/12/16 v2.5j Standard LaTeX font definitions
supp-pdf.mkii
 ***********
  • doesn't work as expected with:
 *File List*
 article.cls    2021/02/12 v1.4n Standard LaTeX document class
  size10.clo    2021/02/12 v1.4n Standard LaTeX file (size option)
luacolor.sty    2021-02-17 v1.17 Color support via LuaTeX's attributes (HO)
   color.sty    2020/02/24 v1.2b Standard LaTeX Color (DPC)
   color.cfg    2016/01/02 v1.6 sample color configuration
  luatex.def    2021/06/01 v1.2c Graphics/color driver for luatex
l3backend-luatex.def    2021-05-07 L3 backend support: PDF output (LuaTeX)
  ts1cmr.fd    2019/12/16 v2.5j Standard LaTeX font definitions
supp-pdf.mkii
 ***********
\documentclass{article}
\usepackage{luacolor}
\paperheight=2cm
\paperwidth=3cm
\ExplSyntaxOn
\AddToHook{shipout/background}
{%
  \put(0.5\paperwidth,-0.5\paperheight)
  {%
    \makebox[0pt][c]{
      \color_fill:n {red}
      RED?
      \color{red}
      RED!
    }
  }%
}
\ExplSyntaxOff
\begin{document}
\mbox{}
\end{document}

@u-fischer
Copy link

| Interestingly, as far as l3color's \color_fill:n is concerned, the following MCE compiled with lualatex:

untested but quite possible. Don't forget that in older LaTeX luacolor didn't work in shipout/background at all and so can't interfere with/overwrite "normal color settings".

@josephwright
Copy link

We have some work in a branch that will add Lua-based color to the core l3color approach, then 'all' I have to do is link it to luacolor!

@u-fischer
Copy link

this issue is resolved. The l3color question should go elsewhere.

@dbitouze
Copy link
Author

this issue is resolved. The l3color question should go elsewhere.

Done here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants